﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        var request = System.Net.HttpWebRequest.Create("http://localhost:53950/SampleSite/handler.ashx");
        request.ContentType = "text/xml;charset=utf-8";
        request.Headers.Add("SOAPAction", "http://tempuri.org/SearchGroupBuy");


        String str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                    "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
                    "<soap:Body><SearchGroupBuy xmlns=\"http://tempuri.org/\"><searchTask><City>" + "上海" + "</City>" +
        "<MinPrice>1000</MinPrice><Category>" + "美食" + "</Category><PageNumber>1</PageNumber>" +
        "</searchTask></SearchGroupBuy></soap:Body></soap:Envelope>";

        request.Method = "POST";
        byte[] data = System.Text.UTF8Encoding.UTF8.GetBytes(str);
        System.IO.Stream newStream = request.GetRequestStream();

        newStream.Write(data, 0, data.Length);
        newStream.Close();
        var response = request.GetResponse();
        System.IO.Stream ReceiveStream = response.GetResponseStream();
        System.Text.Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
        System.IO.StreamReader sr = new System.IO.StreamReader(ReceiveStream, encode);
        str = sr.ReadToEnd();

        return;
       
        WebReference.Service service = new WebReference.Service();
        service.SessionHeaderValue = new WebReference.SessionHeader();

        string key = EBest.Common.Functions.EncryptString("vipuser2password" + "ABCDEFGHJKL");
        var result = service.LocalLogin("vipuser2", "password", key);
        
    }
}
